#include <iostream>

using namespace std;

// given a binary tree, print out all the paths sums to a value
// not the value not necessarily from root to the node

// algorithm: when traversed to a node, check if the node finishes a path sums to the value

struct Node
{
    int value;
    struct Node* left;
    struct Node* right;
};

void PrintBuffer(int buffer[], int start, int level)
{
    for (int i=start; i<level; i++)
    {
        cout << buffer[i] << " ";
    }
    cout << endl;
}

void FindPath(Node* root, int sum, int buffer[], int level)
{
    if (root == NULL)
        return;

    buffer[level] = root->value;
    int temp = sum;

    for (int i=level; i>=0; i--)
    {
        temp -= buffer[i];

        if (temp == 0)
            PrintBuffer(buffer, i, level);
    }

    FindPath(root->left, sum - root->value, buffer, level+1);
    FindPath(root->right, sum - root->value, buffer, level+1);

    return;
}



int main()
{
    return 0;
}